package mvc.unit;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import mvc.form.ActionForm;
/**
 * 
 * @author 柯常荣 2015-7-23 上午11:31:11
 *
 */
public class FullBean {

	public FullBean(){
		
	}
	/**
	 * 返回form表单属性值
	 * @param request
	 * @return
	 */
	public static ActionForm full(HttpServletRequest request){
		ActionForm o = null;
		try {
			Class clazz = Class.forName(request.getParameter("sign"));
			o = (ActionForm)clazz.newInstance();
			Field[] f_ar = clazz.getDeclaredFields();
			for(Field f:f_ar){
				//ActionForm子类中的成员变量为private,故必须进行此操作
				f.setAccessible(true);
				f.set(o, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return o;
	}
}
